#include "editor.h"
#include "binding/binding.h"
#include "imgui/imgui.h"
#include "imgui/imgui_impl_glfw.h"
#include "imgui/imgui_impl_vulkan.h"
#include "scripts/binder/LuaBinder.h"
#include "GLFW/glfw3native.h"
#include "GLFW/glfw3.h"
#include "sol/sol.hpp"


const char *LUA_CODE = R"(require("main")(...))";


int main(int a, char **as) {
    initLog();
    sol::state state;
    LuaBinder::Bind(state);

//    lua.open_libraries();
//    lua_openLibs_sol(&lua);

    try {
        state.script("require('main')(...)", "__startup__");
    } catch (const sol::error &e) {
        LogE("LUA:{}", e.what());
    }

//    lua_State *L = luaL_newstate();
//    lua_openLibs(L);
//    lua_pushinteger(L, a);
//    lua_pushlightuserdata(L, as);
//    if (luaL_loadstring(L, LUA_CODE) != LUA_OK) {
//        LogE("Lua:{0}", lua_tostring(L, -1));
//        return EXIT_FAILURE;
//    }
//    if (lua_pcall(L, 0, LUA_MULTRET, 0) != LUA_OK) {
//        LogE("lua:{0}", lua_tostring(L, -1));
//        return EXIT_FAILURE;
//    }
//    lua_close(L);
    return EXIT_SUCCESS;
}
